package com.glowdayz.glowmee.bc;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.glowdayz.common.CookieBox;

public class LoginBC extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
       
    public LoginBC() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		
		String userAgent = request.getHeader("user-agent");
		
		int check = userAgent.indexOf("Chrome");
		if (check < 0) {
			response.setContentType("text/html; charset=utf-8");
			PrintWriter out = response.getWriter();
			out.print("<script type='text/javascript'>alert('크롬으로만 접속을 해주세요.');history.back();</script>");
			return;
		}
		
		CookieBox cbox = new CookieBox(request, response);
		String save_id = null;
		if (cbox.exists("save_id")) {
			save_id = cbox.getValue("save_id");
			request.setAttribute("save_id", save_id);
		}
		
		RequestDispatcher dpr = request.getRequestDispatcher("/login.jsp");
		dpr.forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}